<style type="text/css">
.normal_form[form-role="dialog"] {padding-top:30px;}
.normal_form[form-role="dialog"] .row.require .select-defined{background-color:#fffbe8;}
.normal_form[form-role="dialog"] .row .field_text {width:180px;}
.normal_form[form-role="dialog"] .input-text{width:350px;}
.normal_form .select-defined-content .select-box-content .select-dl {max-height:280px;}
</style>
<form name="dialogform" class="normal_form" form-role="dialog" onsubmit="return Core.Sys.Dialogform(this);" autocomplete="off">
    <div class="row">
        <div class="field_text">单位名称：</div>
        <input type="text" class="input-text require" name="abname" value="{$res['abname'] ?? ''}" disabled maxlength="100" placeholder="公司名称(简称)"/>
    </div>
    <div class="row">
        <div class="field_text">单位管理员：</div>
        <select class="z-select owner-z-select" name="ownermid" data-style="width:350px">
            <option value="">请选择人员</option>
            {if isset($User) AND $User}
            {foreach $User as $key => $row}
            <option value="{$row['mid'] ?? '0'}" {if ($res['ownermid'] ?? 0)==($row['mid'] ?? 0)} selected{/if}>{$row['realname'] ?? ''}{if ($row['mobile'] ?? '')}({$row['mobile'] ?? ''}){/if}</option>
            {/foreach}
            {/if}
        </select>
    </div>
    
    <div class="row form-footer-bar">
        <p class="colortip"></p>
        <button class="btn" role="btn-cancel">取消</button>
        <button class="btn btn-primary" type="submit" role="btn-submit">保存</button>
    </div>
</form>
<script type="text/javascript">
Core.Sys.Dialogform = function(form){
    var form = $(form);
    var p    = {
        'ownermid' : form.find(".owner-z-select").getZsValue(),
	}
    if (!Core.rule('intp',p['ownermid'])){
		form.find("p.colortip").html('请选择新的管理员!');return false;
	}

	form.find(":button").attr('disabled','disabled');
	$.ajax({type : "POST",dataType: "json",cache : false, url : "{$_G['_mca_']}/ctype/{$ctype ?? 0}/id/{$res['id'] ?? ''}?r="+Math.random(),data : p,success: function(data){
	   try{
		   if (data['state'] == 'y'){
                $('#datalist').datagrid('reload');$(form).dialogClose();
		   } else {
                form.find(":button").removeAttr('disabled');form.find("p.colortip").html(data['msg']);return false;
		   }
	   }catch(e){form.find(":button").removeAttr('disabled');form.find("p.colortip").html('数据提交失败!');return false;}
	}});
	return false;
}
$(function(){

});
</script>